package com.starry.home.ui.main

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.TextView
import com.drake.brv.BindingAdapter
import com.drake.brv.utils.linear
import com.drake.brv.utils.setup
import com.starry.core.base.BaseActivity
import com.starry.home.R
import com.starry.home.databinding.ActivityRecoveryBinding
import com.starry.home.logic.model.hospital.RecoveryBean
import com.starry.home.viewmodel.main.RecoveryViewModel

/**
 * Package:com.starry.home.ui.main
 * Author:starr
 * Time:2024/4/27 10:14
 * Description: 康复治疗计划
 */
class RecoveryActivity : BaseActivity<ActivityRecoveryBinding, RecoveryViewModel>() {
    companion object {
        fun startAction(context: Context) {
            val intent = Intent(context, RecoveryActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun initData() {

    }

    @SuppressLint("NotifyDataSetChanged")
    override fun initView() {

        mDataBinding.titleTopBar.baseTvTitle.text = "康复治疗计划"
        mDataBinding.titleTopBar.baseIvBack.setOnClickListener {
            finish()
        }
        mDataBinding.titleTopBar.baseIvBack.visibility = View.VISIBLE


        mDataBinding.rvTreatment.linear().setup {
            addType<RecoveryBean>(R.layout.item_recovery)
            onBind {
                setRvContent()
            }
        }.apply {
            models = listOf(
                RecoveryBean(
                    " 1.人参保肺丸",
                    " 具有益气补肺，止嗽定喘的功效。用于肺气虚弱，津液亏损引起的虚劳久嗽，气短喘促等症。\n 用量：口服，一次2丸，一日2-3次。"
                ),
                RecoveryBean(
                    " 2.养阴清肺丸", " 具有养阴清肺，清热利咽的功效。用于咽喉干燥疼痛，干咳少痰。\n " +
                            "用量：口服，大蜜丸一次1丸，一日2次。"
                ),
                RecoveryBean(
                    " 3.板蓝根冲剂", " 适用于感受风热所致的咳嗽，胸闷，咽痛等症状。\n " +
                            "用量：通常按照说明书的指导进行，一般是一次1袋，一日3次。"
                ),
                RecoveryBean(
                    " 4.连花清瘟胶囊", " 用于治疗外感风热引起的咳嗽，发热等症状。\n " +
                            "用量：请遵循医嘱或说明书的指导。"
                )
            )

        }
    }

    private fun BindingAdapter.BindingViewHolder.setRvContent() {
        val model = getModel<RecoveryBean>()
        val tvTreatmentContent = findView<TextView>(R.id.tvTreatmentContent)
        val tvTreatmentDetail = findView<TextView>(R.id.tvTreatmentDetail)
        tvTreatmentContent.text = model.drugName
        tvTreatmentDetail.text = model.drugUse
    }

    override fun getLayoutId() = R.layout.activity_recovery
}


